package com.ll.homework;

import java.util.HashSet;

/**
 * @author 刘龙
 * @version 1.0
 */
public class Homework04 {
    public static void main(String[] args) {
        HashSet hashSet = new HashSet();
        Person p1 = new Person(1, "ll");
        Person p2 = new Person(2, "ll2");
        hashSet.add(p1);
        hashSet.add(p2);

        p1.setName("CC");

        System.out.println(hashSet);

        hashSet.remove(p1);

        System.out.println(hashSet);
        hashSet.add(new Person(1, "CC"));

        System.out.println(hashSet);

        hashSet.add(new Person(1, "AA"));
        System.out.println(hashSet);

        hashSet.add(new Person(1, "AA"));
        System.out.println(hashSet);


    }
}

class Person {
    private Integer id;
    private String name;

    public Person(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
